ITSA第34屆比賽 第三題
程式碼:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int strLength, count = 0, i;
string str;
getline(cin, str);
fflush(stdin);
strLength = str.length() - 1;
for(i = 0; i < strLength; ++i)
{
string temp = str.substr(i, 2);
string temp2 = str.substr(i, 4);
if( temp.compare("/n") == 0 || temp.compare("/t") == 0 ||
temp.compare("/a") == 0 || temp.compare("/b") == 0 ||
temp.compare("//") == 0 || temp.compare("/0") == 0 ||
temp.compare("/r") == 0 || temp.compare("/'") == 0 ||
temp.compare("/?") == 0 || temp.compare("/f") == 0 ||
temp.compare("/v") == 0 || temp.compare("/\"") == 0)
{
++i;
++count;
}
else if(temp2.compare("/xhh") == 0 || temp2.compare("/ooo") == 0)
{
i += 3;
++count;
}
}
cout << count << endl;
return 0;
}